/*
** Copyright (C) 2010 Calin Radoni
**
** This file is part of CHScanner.
**
** CHScanner is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** CHScanner is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with CHScanner. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "MFullAddress.h"
#include "MPortInfoList.h"
#include "MSnmpSysRec.h"
#include "MDHCPInfo.h"
#include "MWmiData.h"
#include "MIGMPPacketList.h"
#include "MGxRPList.h"
#include "MSTPList.h"
#include "MCDPList.h"
#include "MDTPList.h"
#include "MDnsNameList.h"
#include "MShareInfoList.h"

#define MAX_NB_NAMES 8

class MMachineInfo
{
private:
	MPortInfoList   thePortList;
	MPortInfoList   theProtoList;
	MIGMPPacketList theIgmpPackList;
	MGxRPList       theGxRPList;
	MSTPList        theStpList;
	MCDPList        theCdpList;
	MDTPList        theDtpList;
	MDnsNameList    theDnsNameList;
	MShareInfoList  theShareInfoList;

	void CleanUp(void);

public:
	MMachineInfo(void);
	~MMachineInfo(void);

	MFullAddress address;

	int pingReplayTime;

	bool recvFin;
	bool recvNull;
	bool recvXmas;
	bool recvUdpSend;
	bool recvIpProto;
	bool recv6Fin;
	bool recv6Null;
	bool recv6Xmas;
	bool recv6UdpSend;
	bool recv6NextHeader;

	int nbNamesCnt;
	CString nbNames[MAX_NB_NAMES];

	MSnmpSysRec snmpSysRec;

	MDHCPInfo infoDHCP;

	bool ssdp;

	MWmiData wmiData;

	bool successfullyStopped;

	bool hunted;

	CString countryCode;

	void Initialize(void);
	bool LoadFromPointer(MMachineInfo*);
	bool LoadFromPointerUpdate(MMachineInfo*);

	bool AddPortInfo(MPortInfo*);
	bool AddPortInfoNoDuplicates(MPortInfo*);
	int GetPortCount(void);
	MPortInfo* GetPortInfo(int);

	bool AddProtoInfo(MPortInfo*);
	int GetProtoCount(void);
	MPortInfo* GetProtoInfo(int);

	bool AddIgmpPack(MIGMPPacket*);
	bool AddIgmpPackNoDuplicates(MIGMPPacket*);
	int GetIgmpPackCount(void);
	MIGMPPacket* GetIgmpPack(int);

	bool AddGxRPPack(MGxRPPacket*);
	bool AddGxRPPackNoDuplicates(MGxRPPacket*);
	int GetGxRPPackCount(void);
	MGxRPPacket* GetGxRPPack(int);

	bool AddSTPPack(MSTPPacket*);
	bool AddSTPPackNoDuplicates(MSTPPacket*);
	int GetSTPPackCount(void);
	MSTPPacket* GetSTPPack(int);

	bool AddCDPPack(MCDPPacket*);
	bool AddCDPPackNoDuplicates(MCDPPacket*);
	int GetCDPPackCount(void);
	MCDPPacket* GetCDPPack(int);

	bool AddDTPPack(MDTPPacket*);
	bool AddDTPPackNoDuplicates(MDTPPacket*);
	int GetDTPPackCount(void);
	MDTPPacket* GetDTPPack(int);

	bool AddDnsName(MDnsName*);
	bool AddDnsNameNoDuplicates(MDnsName*);
	int GetDnsNameCount(void);
	MDnsName* GetDnsName(int);

	bool AddShareInfo(MShareInfo*);
	bool AddShareInfoNoDuplicates(MShareInfo*);
	int GetShareInfoCount(void);
	MShareInfo* GetShareInfo(int);

	void SortPortInfo(void);
	void SortProtoInfo(void);
	void SortIgmpPacks(void);
	void SortShareInfo(void);

	bool IsTcpPortOpen(WORD);
	bool IsUdpPortOpen(WORD);
};
